<template>
  <hi-row
    isColumn
    :wrap="false"
    class="viewcontainer"
    v-if="dataset && subDataSet"
  >
    <hi-col flex="260px">
      <hi-form
        :dataSource="dataset"
        ref="detailForm"
        :model="dataset.curRecord"
        v-bind="form"
      ></hi-form>
    </hi-col>
    <hi-col flex="auto" :min-height="200">
      <hi-table
        ref="detailTable"
        :dataSource="subDataSet"
        v-bind="dataTable"
        :model="subDataSet.data"
      ></hi-table>
    </hi-col>
  </hi-row>
</template>

<script>
import { HiForm, HiTable } from "hi-ui";
import viewBase from "../../base";
import cashierListCfg from "./dataset/cashierList";
import salesGoodsCfg from "./dataset/salesGoods";
export default {
  name: "salesGoods",
  extends: viewBase,
  components: { HiForm, HiTable },

  data() {
    return {
      //数据集
      dataset: null,
      //数据集配置
      datasetCfg: cashierListCfg,
      //从表数据集
      subDataSet: null,
      //从表数据集配置
      subDatasetCfg: salesGoodsCfg,

      //数据桥梁
      dataBridge: new Map(),
      //数据表格
      dataTable: {
        // isEdit: true,
        // hasSelection: true,
        // hasRowNumber: true,

        columns: [
          {
            name: "FGOODSNUMBER",
          },
          {
            name: "FBARCODE",
          },

          {
            name: "FDESC",
          },
          {
            name: "FBRAND",
          },
          {
            name: "FSPEC",
          },
          {
            name: "FUNIT",
          },
          {
            name: "FAMOUNT",
            props: {
              precision: 2,
            },
          },

          {
            name: "FPRICE",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },
          {
            name: "FDISCOUNT",
          },
          {
            name: "FDISCOUNTPRICE",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },
          {
            name: "FDISCOUNTFMONEY",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },
        ],
      },
      //表单配置
      form: {
        columnsTotal: 2,
        items: [
          {
            name: "FNUMBER",
          },

          {
            name: "FGOODSAMOUNT",
          },
          {
            name: "FORDERMONEY",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },
          {
            name: "FRECEIVABLEMONEY",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },
          {
            name: "FCOLLECTIONMONEY",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },
          {
            name: "FCHANGEMONEY",
            props: {
              format: "￥0.00",
              precision: 2,
            },
          },

          {
            name: "FSHOPDESC",
            element: "el-input",
          },
          {
            name: "FENTERPRISEDESC",
          },
          /*     {
            name: "FENTERPRISEID",
           
          }, */
          {
            name: "FUSERDESC",
          },
          {
            name: "FCREATEDATE",
          },

          /*      {
            name: "FAUDIT",
            element: "el-input",
          }, */
        ],
      },
    };
  },

  computed: {},
  watch: {},
  methods: {},
  mounted() {
    //创建主数据集
    this.dataset = this.createDataSet(this.datasetCfg);
    this.dataset.on("dirtychange", (store, dirty) => {
      console.log("dataset" + dirty);
    });
    //创建从数据集
    this.subDataSet = this.createDataSet(this.subDatasetCfg, this.dataset);

    //设置数据与组件的关系
    this.dataBridge.set(this.dataset, ["detailForm", "detailTable"]);
    this.flowConfig = { dataset: this.dataset };
    if (this.$route.query.id) {
      this.dataset.load({
        FID: this.$route.query.id,
      });
    }
  },
};
</script>
<style rel="stylesheet/scss" lang="scss" scope>
</style>

